package day8;

import java.util.Scanner;

public class Main {
     public static boolean lexicographically(String[] str){
         boolean ret =true;
         for(int i=0;i<str.length-1;i++){
             if(str[i].compareTo(str[i+1])>0){
                 return false;
             }
         }
         return ret;
     }
    
     public static boolean length(String[] str){
         boolean ret =true;
         for(int i=0;i<str.length-1;i++){
             if(str[i].length()>str[i+1].length()){
                 return false;
             }
         }
         return ret;
     }
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            in.nextLine();
            String[] str=new String[n];
            for(int i=0;i<n;i++){
                str[i]=in.nextLine();
            }
            if(length(str)&&lexicographically(str)){
                System.out.println("both");
            }
            else if(length(str)){
                System.out.println("lengths");
            }
            else if(lexicographically(str)){
                System.out.println("lexicographically");
            }
            else{
                System.out.println("none");
            }
        }
    }
}


//             System.out.println(a + b);